package defpackage; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.net.Uri; import android.os.Build; import android.support.v4.media.session.PlaybackStateCompat; import android.text.TextUtils; import android.util.DisplayMetrics; import android.view.ContextThemeWrapper; import cn.wps.moffice.OfficeApp; import cn.wps.moffice.main.common.ServerParamsUtil; import cn.wps.moffice.main.push.common.PushBean; import cn.wps.shareplay.message.Message; import defpackage.hae; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.text.DecimalFormat; import java.util.HashMap; import java.util.Map; import org.eclipse.paho.client.mqttv3.internal.ClientDefaults; /* renamed from: hai reason: default package */ public final class hai { public static String A(String str, String str2, String str3) { String IR; try { IR = hae.yz(str); } catch (hae.a e) { IR = lwv.IR(str); } String str4 = OfficeApp.arx().arM().lZx + str2 + File.separator + str3 + File.separator + IR; File file = new File(str4); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } return str4; } /* JADX WARNING: Removed duplicated region for block: B:19:0x0029 A[SYNTHETIC, Splitter:B:19:0x0029] */ /* JADX WARNING: Removed duplicated region for block: B:26:0x0036 A[SYNTHETIC, Splitter:B:26:0x0036] */ private static long G(File file) { FileInputStream fileInputStream; Throwable th; IOException e; long j = 0; if (file.exists() && file.isFile()) { try { fileInputStream = new FileInputStream(file); try { j = (long) fileInputStream.available(); try { fileInputStream.close(); } catch (IOException e2) { e2.printStackTrace(); } } catch (IOException e3) { e = e3; try { e.printStackTrace(); if (fileInputStream != null) { } return j; } catch (Throwable th2) { th = th2; if (fileInputStream != null) { } throw th; } } } catch (IOException e4) { e = e4; fileInputStream = null; e.printStackTrace(); if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e5) { e5.printStackTrace(); } } return j; } catch (Throwable th3) { th = th3; fileInputStream = null; if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e6) { e6.printStackTrace(); } } throw th; } } return j; } public static boolean a(PushBean pushBean, String str, boolean z) { try { try { String aa = hae.aa(new File(A(pushBean.url, str, pushBean.serverType))); return !TextUtils.isEmpty(aa) && aa.equals(pushBean.md5); } catch (hae.a e) { } } catch (Exception e2) { } } private static String ak(long j) { try { DecimalFormat decimalFormat = new DecimalFormat("#.00"); return j < 1024 ? decimalFormat.format((double) j) + "B" : j < PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED ? decimalFormat.format(((double) j) / 1024.0d) + "K" : j < 1073741824 ? decimalFormat.format(((double) j) / 1048576.0d) + "M" : decimalFormat.format(((double) j) / 1.073741824E9d) + "G"; } catch (Exception e) { e.printStackTrace(); return ""; } } public static void bc(Context context, String str) { if (str != null) { try { if (!yG(str) || !lwg.hB(context)) { ltp.bU(context, str); return; } Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str)); intent.setPackage("com.android.vending"); if (!(context instanceof ContextThemeWrapper)) { intent.addFlags(ClientDefaults.MAX_MSG_SIZE); } context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } } } public static boolean dS(Context context) { return hwd.isWifiConnected(context) || lwd.hv(context); } public static boolean f(PushBean pushBean) { try { if (pushBean.remark != null && !TextUtils.isEmpty(pushBean.remark.netUrl)) { return pushBean.remark.netUrl.contains("https://play.google.com/store/apps/details?id="); } return false; } catch (Exception e) { return false; } } public static boolean g(PushBean pushBean) { return pushBean.remark == null || TextUtils.isEmpty(pushBean.name) || TextUtils.isEmpty(pushBean.type) || TextUtils.isEmpty(pushBean.md5) || TextUtils.isEmpty(pushBean.url) || TextUtils.isEmpty(pushBean.serverType) || TextUtils.isEmpty(pushBean.remark.resourceUrl) || TextUtils.isEmpty(pushBean.remark.resourceUrlMd5) || TextUtils.isEmpty(pushBean.platform) || !"android".equals(pushBean.platform); } /* JADX WARNING: Removed duplicated region for block: B:21:0x0054 A[SYNTHETIC, Splitter:B:21:0x0054] */ /* JADX WARNING: Removed duplicated region for block: B:28:0x0061 A[SYNTHETIC, Splitter:B:28:0x0061] */ public static Bitmap i(Context context, String str, String str2, String str3) { FileInputStream fileInputStream; Throwable th; Exception e; BitmapFactory.Options options = null; String A = A(str, str3, str2); Bitmap yF = hag.bXI().yF(A); if (yF == null) { try { fileInputStream = new FileInputStream(A); try { if (luf.gQ(context)) { options = new BitmapFactory.Options(); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); options.inScreenDensity = displayMetrics.densityDpi; options.inTargetDensity = displayMetrics.densityDpi; int i = Build.VERSION.SDK_INT; options.inDensity = 480; } yF = BitmapFactory.decodeStream(fileInputStream, null, options); if (yF != null) { hag.bXI().d(A, yF); } try { fileInputStream.close(); } catch (Exception e2) { e2.printStackTrace(); } } catch (Exception e3) { e = e3; try { e.printStackTrace(); if (fileInputStream != null) { try { fileInputStream.close(); } catch (Exception e4) { e4.printStackTrace(); } } return yF; } catch (Throwable th2) { th = th2; if (fileInputStream != null) { try { fileInputStream.close(); } catch (Exception e5) { e5.printStackTrace(); } } throw th; } } } catch (Exception e6) { e = e6; fileInputStream = null; e.printStackTrace(); if (fileInputStream != null) { } return yF; } catch (Throwable th3) { th = th3; fileInputStream = null; if (fileInputStream != null) { } throw th; } } return yF; } public static String oM(boolean z) { return z ? ".cn" : ".en"; } public static Bitmap p(Bitmap bitmap) { Bitmap bitmap2; try { DisplayMetrics displayMetrics = OfficeApp.arx().getResources().getDisplayMetrics(); Matrix matrix = new Matrix(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; int i = options.outWidth; int i2 = options.outHeight; float f = i <= 48 ? 1.0f : i <= 72 ? 1.5f : i <= 96 ? 2.0f : 3.0f; float f2 = luf.gQ(OfficeApp.arx()) ? displayMetrics.density / f : displayMetrics.density >= 2.0f ? (1.0f / f) + displayMetrics.density : (float) ((((double) displayMetrics.density) + 0.5d) / ((double) f)); options.inJustDecodeBounds = false; matrix.postScale(f2, f2); bitmap2 = Bitmap.createBitmap(bitmap, 0, 0, i, i2, matrix, false); } catch (Exception e) { e.printStackTrace(); bitmap2 = null; } return bitmap2 == null ? bitmap : bitmap2; } public static Map<String, String> r(String str, long j) { HashMap hashMap = new HashMap(); if (str != null) { try { hashMap.put("fileSize", ak(G(new File(str)))); } catch (Exception e) { e.printStackTrace(); } } hashMap.put("loadedTime", String.valueOf(j)); return hashMap; } public static boolean yG(String str) { try { if (TextUtils.isEmpty(str)) { return false; } return str.contains("https://play.google.com/store/apps/details?id="); } catch (Exception e) { return false; } } public static String[] yH(String str) { Exception e; String[] strArr; String[] strArr2 = null; try { ServerParamsUtil.Params tG = ServerParamsUtil.tG(str); if (tG == null || tG.result != 0) { return null; } String[] strArr3 = null; for (ServerParamsUtil.Extras extras : tG.extras) { try { if (!TextUtils.isEmpty(extras.key) && !TextUtils.isEmpty(extras.value)) { if ("tips_title".equals(extras.key)) { strArr = extras.value.split(extras.value.contains(Message.SEPARATE) ? Message.SEPARATE : ","); try { if (strArr.length < 2) { strArr = null; } } catch (Exception e2) { strArr2 = strArr; e = e2; e.printStackTrace(); return strArr2; } } else { strArr = strArr3; } strArr3 = strArr; } } catch (Exception e3) { e = e3; strArr2 = strArr3; e.printStackTrace(); return strArr2; } } return strArr3; } catch (Exception e4) { e = e4; e.printStackTrace(); return strArr2; } } }